package nl.foldervisualizer
/**
 * Date: 3-jun-2008
 * Time: 21:43:43
 */
class TestVisualizer {
    public static void main(String[] args) {
        FolderVisualizer visualizer = FolderVisualizer.create(new Folder(args[0]))

        int limit = 10
        if (args.length > 1) {
            limit = Integer.parseInt(args[1])
        }

        Scanner scanner = new Scanner(System.in)
        String command = scanner.nextLine()
        while (!("exit".equalsIgnoreCase(command))) {
            try {
                List toVisualize = visualizer.toVisualize(new Folder(command), limit)

                toVisualize.collect {
                    print it.path + " (" + it.bytes + " bytes)"
                    (80 - it.path.length() - it.bytes.toString().length()).times {
                        print "-"
                    }
                    print "> "
                    int times = it.relativeSize.round()
                    if (times == 0) times = 1
                    times.times {
                        print "X"
                    }
                    println ""
                }
            } catch (IllegalArgumentException e) {
                println e.getMessage()
            }

            command = scanner.nextLine()
        }
    }
}